<?php
if (isset($_POST['submit'])) {
	$fn = $_POST['firstname'];
	$ln = $_POST['lastname'];
	$addr = $_POST['address'];
	$city = $_POST['city'];
	$zipcode = $_POST['zipcode'];
	$state = $_POST['state'];
	$country = $_POST['country'];
	$phone = $_POST['phone'];
	
	$_SESSION['firstName'] = $fn;
	$_SESSION['lastName'] = $ln;
	$_SESSION['address'] = $addr;
	$_SESSION['city'] = $city;
	$_SESSION['zipcode'] = $zipcode;
	$_SESSION['state'] = $state;
	$_SESSION['country'] = $country;
	$_SESSION['phone'] = $phone;
	
	$m = $_SESSION['m'];
	if ($m == 1) {
	$arrAddresses = array(
		array(
			"mode" => "shipping",
			"firstname" => $fn,
			"lastname" => $ln,
			//"company" => "testCompany",
			"street" => $addr,
			"city" => $city,
			"region" => $state,
			"postcode" => $zipcode,
			"country_id" => $country,
			"telephone" => $phone,
			//"fax" => "0123456789",
			//"is_default_shipping" => 0,
			//"is_default_billing" => 0
		),
		array(
			"mode" => "billing",
			"firstname" => $fn,
			"lastname" => $ln,
			//"company" => "testCompany",
			"street" => $addr,
			"city" => $city,
			"region" => $state,
			"postcode" => $zipcode,
			"country_id" => $country,
			"telephone" => $phone,
			//"fax" => "0123456789",
			//"is_default_shipping" => 0,
			//"is_default_billing" => 0
		)
	);
	$cid = $_SESSION['cid'];
	$resultCustomerAddresses = $soap->call($session_id, "cart_customer.addresses", array($cid, $arrAddresses));
	}
	header("location: shippingmethod.php");
}
?>